package com.yonyou.pmclouds.project.processor;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.project.entity.ProjectVO;
import org.apache.commons.lang3.StringUtils;

public class ProjectUpdateCheck implements SingleProcessor<ProjectVO> {
    private String operator;

    public ProjectUpdateCheck(String operator) {
        this.operator = operator;
    }

    @Override
    public void process(ProjectVO vo, ProjectVO orig) throws BusinessException {
        // 不再校验竣工的状态 since 2.4
//        if (orig.getProjectState() == ProjectConst.STATE_END) {
//            throw new BusinessException("已经结束的项目不可以编辑！");
//        }
        if (!StringUtils.equals(orig.getManager(), operator) && !StringUtils.equals(orig.getCreator(), operator)) {
            throw new BusinessException("只有该项目的项目经理或创建人才可以编辑该项目！");
        }
    }
}
